import js from "@eslint/js"
import globals from "globals"
import vueParser from "vue-eslint-parser"
import tsParser from "@typescript-eslint/parser"
import pluginVue from "eslint-plugin-vue"
import { defineConfig } from "eslint/config"
console.log(pluginVue.configs['flat/recommended'])

export default defineConfig([
  {
      // 忽略 CSS 文件
      ignores: ['**/*.css', '**/*.scss', '**/*.less', '**/env.d.ts']
  },
  {
    files: ["src/**/*.{js,mjs,cjs,ts,mts,cts,vue}"],
    plugins: { js, vue: pluginVue },
    extends: ["js/recommended"],
    languageOptions: {
      globals: {
        ...globals.browser,
      }
    },
    rules: {
      ...js.configs.recommended.rules,
      "no-semi": 0,
      // 'no-console': 'error',
      'semi': ['error', 'never'],
      "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_"}]
    }
  },
  {
    files: ["*.vue", "**/*.vue", "src/**/*.ts"],
    languageOptions: {
        parser: vueParser,
        parserOptions: {
            "parser": {
                // Script parser for `<script>`
                // "js": "espree",

                // Script parser for `<script lang="ts">`
                "ts": tsParser,

                // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
                // and vue interpolations (e.g. `{{variable}}`).
                // If not specified, the parser determined by `<script lang ="...">` is used.
                // "<template>": "espree",
            }
        }
    }
  },
])
